
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div class="form">
            <div class="item">
                <label for="">用户名</label>
                <input type="text" class="user" v-model="userInfo.user">
            </div>
            <div class="item">
                <label for="">密码</label>
                <input type="password" class="pwd" v-model="userInfo.pwd">
            </div>
            <button class="login" @click="login()">登录</button>
            <button class="info" @click="getInfo()">获取信息</button>

        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.js"></script>
    <script>
        // axios.interceptors.request.use(
        //     config => {
        //         const token = window.localStorage.token;
        //         if (token) {
        //             config.headers.common["Authorization"] = "Bearer " + token
        //         }
        //         return config
        //     },
        //     err => {
        //         return Promise.reject(err)
        //     }

        // )
        axios.defaults.withCredentials = true;
        var app = new Vue({
            el: '#app',
            data: {
                message: 'hello world',
                userInfo: {
                    user: '',
                    pwd: ''
                }

            },
            methods: {
                login() {
                    // console.log(1);
                    axios.post('http://localhost:3000/login', this.userInfo).then(res => {
                        console.log(res);
                        
                    })

                },
                
                getInfo() {
                    axios.post('http://localhost:3000/getuser',this.userInfo).then();
                }
            }
        })
    </script>
</body>

</html>